<?php

include "../../lib/start.php";

check_session();
check_permission(DOC_PERM);

// estrazione ultimi documenti pubblicati
$number_docs = 3;
$sel_docs = "(SELECT id_work, data_inserimento AS data, file, '1' AS doc_type, abstract, titolo, '' AS link, anno, CONCAT(classi.anno_corso, classi.sezione) AS classe FROM stud_works, classi WHERE stud_works.classe = classi.id_classe) UNION (SELECT id, data_upload AS data, file, doc_type, abstract, titolo, link, '' AS anno, '' AS classe FROM documents) ORDER BY data DESC LIMIT $number_docs";
$res_docs = $db->execute($sel_docs);

// estrazione documenti in evidenza
$sel_ev_docs = "SELECT id, evidenziato AS data, file, doc_type, abstract, titolo, link FROM documents WHERE evidenziato IS NOT NULL AND evidenziato > NOW() ORDER BY data_upload DESC LIMIT 5";
$res_ev = $db->execute($sel_ev_docs);

include "docs.html.php";

?>